using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace DynamicFrom
{
    /// <summary>
    /// 产品信息示例类
    /// </summary>
    public class Product
    {
        public List<Double> CalibrationCoefficientAForY { get; set; }

        public double[] Ids { get; set; }

        [DisplayName("产品名称")]
        [Required(ErrorMessage = "产品名称必填")]
        public string Name { get; set; } = "智能手表Pro";

        [DisplayName("产品编号")]
        public string SKU { get; set; } = "WP-2023-001";

        [DisplayName("生产信息")]
        public List<ManufacturingInfo> ManufacturingInfo { get; set; } = new List<ManufacturingInfo>();

        [DisplayName("单价")]
        [Range(0, 100000, ErrorMessage = "单价必须大于0且小于100000")]
        public decimal Price { get; set; } = 1299.99m;

        [DisplayName("库存量")]
        [Range(0, 10000, ErrorMessage = "库存量必须是有效数字")]
        public int StockQuantity { get; set; } = 250;

        [DisplayName("上架日期")]
        public DateTime ReleaseDate { get; set; } = DateTime.Now;

        [DisplayName("是否在售")]
        public bool IsAvailable { get; set; } = true;

        [DisplayName("产品类别")]
        public ProductCategory Category { get; set; } = ProductCategory.Electronics;

        [DisplayName("产品描述")]
        //[Description("产品详细描述")]
        public string Description { get; set; } = "这是一款功能丰富的智能手表，支持心率监测、运动追踪和消息提醒等功能。\n采用高清彩屏，续航长达7天。";
    }

    /// <summary>
    /// 生产信息类
    /// </summary>
    public class ManufacturingInfo
    {
        [DisplayName("制造商")]
        public string Manufacturer { get; set; } = "科技智造有限公司";

        [DisplayName("生产地")]
        public string Location { get; set; } = "深圳市";

        [DisplayName("保修期(月)")]
        [Range(0, 60, ErrorMessage = "保修期必须在0-60个月之间")]
        public int WarrantyMonths { get; set; } = 12;

        [DisplayName("质量等级")]
        public QualityGrade QualityGrade { get; set; } = QualityGrade.Premium;
    }

    /// <summary>
    /// 产品类别枚举
    /// </summary>
    public enum ProductCategory
    {
        [Description("电子产品")]
        Electronics,

        [Description("服装")]
        Clothing,

        [Description("食品")]
        Food,

        [Description("家居")]
        HomeAppliances,

        [Description("办公用品")]
        OfficeSupplies
    }

    /// <summary>
    /// 质量等级枚举
    /// </summary>
    public enum QualityGrade
    {
        [Description("普通")]
        Standard,

        [Description("优质")]
        Premium,

        [Description("精品")]
        Deluxe
    }
}